package com.rocksea.app.activity;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;

import com.rocksea.app.fragment.CommonBaseInfoFragment;
import com.rocksea.app.fragment.LowStrainDataFragment;
import com.rocksea.app.fragment.LowStrainUnValidViewFragment;
import com.rocksea.app.fragment.LowStrainViewFragment;
import com.rocksea.app.fragment.PhotoFragment;


/**
 * Created by 吴志华 on 2017/10/26.
 * @FileName:com.rocksea.app.activity.LowStrainActivity.java
 */

public class LowStrainActivity extends BaseShowActivity {
    private static String[] TITLES = {"基本信息","有效波形图","无效波形图","现场照片"};
    @Override
    public void addFragment(ViewPager viewPager) {
        CommonFragmentAdapter lowStrainFragmentAdapter = new CommonFragmentAdapter(getSupportFragmentManager());
        viewPager.setAdapter(lowStrainFragmentAdapter);
    }

    @Override
    protected void actionBarTitle(ActionBar actionBar)
    {
        actionBar.setTitle(String.format("%s-低应变信息",infos[1]));
    }

    @Override
    public void initData()
    {
        String baseInfoId = infos[2];
        mBundle = new Bundle();
        mBundle.putString(BaseShowActivity.BASEINFOID_KEY,baseInfoId);
        mBundle.putString(BaseShowActivity.PLAN_NUM_KEY,infos[0]);
        mBundle.putString(BaseShowActivity.PLIE_NO_KEY,infos[1]);
    }
    public class CommonFragmentAdapter extends FragmentPagerAdapter{
        private CommonFragmentAdapter(FragmentManager fm)
        {
            super(fm);
        }
        @Override
        public Fragment getItem(int i)
        {
            switch (i)
            {
                case 0:
                    return CommonBaseInfoFragment.newInstance(mBundle);
                case 1:
                    mBundle.putInt(LowStrainViewFragment.VALID_KEY,LowStrainViewFragment.VALID);
                    return LowStrainViewFragment.newInstance(mBundle);
                case 2:
                    mBundle.putInt(LowStrainViewFragment.VALID_KEY,LowStrainViewFragment.UN_VALID);
                    return LowStrainUnValidViewFragment.newInstance(mBundle);
                case 3:
                    return PhotoFragment.newInstance(mBundle);
                default:
                    return null;
            }
        }
        @Override
        public int getCount()
        {
            return TITLES.length;
        }
        @Override
        public CharSequence getPageTitle(int position)
        {
            return TITLES[position];
        }

    }

}
